# -*- coding: UTF-8 -*-

"""Google Search Module for Pyrc"""

key = 'llLy/pxQFHKsfe+ta8MSWoc4JmKi9/+c'
from SOAPpy import WSDL

def cerca(pyrc,umask,dest,message):
    if umask[0] != "andrea-bs":
        server = WSDL.Proxy('http://api.google.com/GoogleSearch.wsdl')
        results = server.doGoogleSearch(key, message[0], 0, 3, True, "", False, "lang_it", "utf-8", "utf-8")
        for j,r in enumerate(results.resultElements):
            pyrc.msg(dest[0],"%d - %s" % (j+1,r.URL))
        
events = [
    ['PRIVMSG','(.+)!.+','(.+)','!beeseek (.+)',cerca],
    ['PRIVMSG','(.+)!.+','(.+)','!bsk (.+)',cerca],
    ['PRIVMSG','(.+)!.+','(.+)','!google (.+)',cerca],
]
